from typing import TypeVar, Generic

T = TypeVar('T')


class Response(Generic[T]):

    def __init__(self, code: str, data: T, msg: str):
        self.code = code
        self.data = data
        self.msg = msg

    @classmethod
    def success(cls, data=None, msg='ok') -> 'Response':
        return cls('success', data, msg)

    @classmethod
    def fail(cls, msg='fail', data=None):
        return cls('fail', data, msg)
